package com.chanzany.adapter.springMVCAdapter;

//定义一个Adapter接口
public interface HandlerAdapter {
    boolean support(Object handler);
    void handle(Object handler);
}
//多种具体适配器类
class HttpHandlerAdapter implements HandlerAdapter{

    @Override
    public boolean support(Object handler) {
        return (handler instanceof HttpController);
    }

    @Override
    public void handle(Object handler) {
        ((HttpController) handler).handle();
    }
}

class SimpleHandlerAdapter implements HandlerAdapter{

    @Override
    public boolean support(Object handler) {
        return (handler instanceof SimpleController);
    }

    @Override
    public void handle(Object handler) {
        ((SimpleController) handler).handle();
    }
}
class AnnotationHandlerAdapter implements HandlerAdapter{

    @Override
    public boolean support(Object handler) {
        return (handler instanceof AnnotationController);
    }

    @Override
    public void handle(Object handler) {
        ((AnnotationController) handler).handle();
    }
}

